// 封装axios：统一管理接口API
import axios from '../request';
interface User {
    key: string;
    identity: string;
    img: string; 
    username: string;
    pohone: string | number;
    phone: string | number;
    password: string | number;
    oldpsw: string | number;
    email: string;
    sex: string;
    registerTime: string;
    area: string;  //意向区间
    budget: string;  //总价预算
    purpose: string;  //买房目的
}

// 注册
export const register = async (data:User) => {
    const {username,email,password,pohone} = data
    const res = await axios.post('/user/register',{
        username,email,password,pohone
    });
    return res;
};
// 登录
export const login = async (data:User) => {
    const {username,password} = data
    const res = await axios.post('/user/login',{
        username,password
    });
    return res;
};
// 密码修改
export const changepsw  = async (data:User) => {
    const {username,password,oldpsw} = data
    const res = await axios.post('/user/changepsw',{
        username,password,oldpsw
    });
    return res;
};
// 修改个人信息
export const userEdit  = async (data:User) => {
    const {username,sex,area,budget,purpose} = data
    const res = await axios.post('/user/edit ',{
        username,sex,area,budget,purpose
    });
    return res;
};
// 获取用户信息
export const usermsg = async () => {
    const res = await axios.get('/usermsg/');
    return res;
};
// 删除 用户列表信息
export const usermsgDel = async (data:User) => {
    const res = await axios.post('/usermsg/del');
    return res;
};
// 添加 用户列表信息
export const adduser = async (data:User) => {
    const {username,phone,password,email,registerTime} = data
    const res = await axios.post('/usermsg/adduser',{
        username,phone,password,email,registerTime
    });
    return res;
};
// 修改 用户列表信息
export const edituser = async (data:User) => {
    const {username,phone,password,email,registerTime} = data
    const res = await axios.post('/usermsg/edituser',{
        username,phone,password,email,registerTime
    });
    return res;
};
//  头像上传
export const fil  = async (data:User) => {
    const res = await axios.post('/usermsg/fil');
    return res;
};


export default {}